package cn.itsource.service.impl;

import cn.itsource.pojo.domain.DriverSetting;
import cn.itsource.mapper.DriverSettingMapper;
import cn.itsource.pojo.properties.DriverProperties;
import cn.itsource.service.IDriverSettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 司机配置 服务实现类
 * </p>
 *
 * @author tom
 * @since 2024-03-14
 */
@Service
public class DriverSettingServiceImpl extends ServiceImpl<DriverSettingMapper, DriverSetting> implements IDriverSettingService {

    @Autowired
    private DriverProperties driverProperties;

    @Override
    public void create(Long id) {
        DriverSetting setting = new DriverSetting()
                .setId(id)
                .setCreateTime(new Date())
                .setListenService(true)
                .setAutoAccept(true)
                .setOrientation(true)
                .setOrderDistance(driverProperties.getOrderDistance())
                .setRangeDistance(driverProperties.getRangeDistance());
        super.save(setting);
    }
}
